package homeWork_10_1.Exam1_2;

public class Goods {
    private String name;
    private int price;
    private String producer;
    private int number;
    private int flag;

    public Goods(String name, int price, String producer, int number) {
        this.name = name;
        this.price = price;
        this.producer = producer;
        this.number = number;
        this.flag = 0;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getProducer() {
        return producer;
    }

    public void setProducer(String producer) {
        this.producer = producer;
    }

    public int getNumber() {
        return number;
    }

    public Goods() {
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public boolean Sale(){
        if (number>1){
            number--;
            return true;
        }else{
            return false;
        }
    }

    public boolean Add(){
        if (flag==1)
            return false;
        flag = 1;
        return true;
    }

    @Override
    public String toString() {
        return "Goods{" +
                "name='" + name + '\'' +
                ", price=" + price +
                ", producer='" + producer + '\'' +
                ", number=" + number +
                ", flag=" + flag +
                '}';
    }
}
